package voting

import (
	"errors"

	"awfan.cn/utils"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

func remove(id string, w http.ResponseWriter, body []byte,db *mgo.Database)() {
	if id == "" {
		return nil, &utils.RESP_ERROR{404, errors.New("#id is empty")}
	}

	c := db.C(utils.PkgName(VOTINGS_XML{}))

	err := c.RemoveId(bson.ObjectIdHex(id))

	if err != nil {

		return nil, &utils.RESP_ERROR{404, err}
	}

	return "{}", nil
}
